`:top
`!Java Native Access`! (`!JNA`!) ist eine `F33f`_`[Java`:/page/entry.mu`zim=wikipedia_de_all_nopic_2026-01.zim|entry_path=Java_(Programmiersprache)]`_`f-`F33f`_`[Programmbibliothek`:/page/entry.mu`zim=wikipedia_de_all_nopic_2026-01.zim|entry_path=Programmbibliothek]`_`f für den Zugriff auf `F33f`_`[plattformspezifische`:/page/entry.mu`zim=wikipedia_de_all_nopic_2026-01.zim|entry_path=Plattform_(Computer)]`_`f („native“) `F33f`_`[dynamische Programmbibliotheken`:/page/entry.mu`zim=wikipedia_de_all_nopic_2026-01.zim|entry_path=Programmbibliothek]`_`f (`F33f`_`[DLLs`:/page/entry.mu`zim=wikipedia_de_all_nopic_2026-01.zim|entry_path=Dynamic_Link_Library]`_`f in Windows oder „shared libraries“ auf anderen Systemen). Hierbei braucht im Unterschied zu `F33f`_`[Java Native Interface`:/page/entry.mu`zim=wikipedia_de_all_nopic_2026-01.zim|entry_path=Java_Native_Interface]`_`f (JNI) kein plattformspezifischer Code geschrieben zu werden.
JNA ist in der Funktion mit den Platform Invocation Services (P/Invoke) des `F33f`_`[.Net-Frameworks`:/page/entry.mu`zim=wikipedia_de_all_nopic_2026-01.zim|entry_path=.Net-Framework]`_`f unter Windows vergleichbar. Es unterstützt eine automatische Umwandlung zwischen einigen C- und Java-`F33f`_`[Datentypen`:/page/entry.mu`zim=wikipedia_de_all_nopic_2026-01.zim|entry_path=Datentyp]`_`f. Die minimal erforderliche Java-Version ist 1.4.
>>Contents
• `F0af`_`[Lizenz`#lizenz]`_`f
• `F0af`_`[Mapping der Datentypen`#mapping-der-datentypen]`_`f
• `F0af`_`[Anwendungen`#anwendungen]`_`f
• `F0af`_`[Beispiel`#beispiel]`_`f
• `F0af`_`[Weblinks`#weblinks]`_`f
• `F0af`_`[Einzelnachweise`#einzelnachweise]`_`f
-─
>>Lizenz
`F33f`_`[LGPL`:/page/entry.mu`zim=wikipedia_de_all_nopic_2026-01.zim|entry_path=GNU_Lesser_General_Public_License]`_`f Version 2.1 oder höher und (ab V4.0) die `F33f`_`[Apache Software License`:/page/entry.mu`zim=wikipedia_de_all_nopic_2026-01.zim|entry_path=Apache_Software_License]`_`f V2.0.`:cite-ref-1[`F5bf`_`[1`#cite-note-1]`_`f]
>>Mapping der Datentypen
Die folgende Tabelle zeigt, wie das Mapping zwischen Java und dem nativen Code mit JNA erfolgt.`:cite-ref-2[`F5bf`_`[2`#cite-note-2]`_`f]
`t
| Nativer Typ | Größe | Java Typ | Standard Windows Type |
|---|---|---|---|
| char | 8-bit integer | byte | BYTE, TCHAR |
| short | 16-bit | short | short WORD |
| wchar_t | 16/32-bit character | char | WCHAR, TCHAR |
| int | 32-bit integer | int | DWORD |
| int | boolean value | boolean | BOOL |
| long | 32/64-bit integer | NativeLong | LONG |
| long long, __int64 | 64-bit integer | long | |
| float | 32-bit FP | float | |
| double | 64-bit FP | double | |
| char* | C string | String | LPCTSTR |
| void* | pointer | Pointer | LPVOID, HANDLE, LPXXX |
`t
>>Anwendungen
Die folgenden Softwareprojekte verwenden JNA:
• `F33f`_`[JRuby`:/page/entry.mu`zim=wikipedia_de_all_nopic_2026-01.zim|entry_path=JRuby]`_`f
• `F33f`_`[Java Media Framework#FMJ`:/page/entry.mu`zim=wikipedia_de_all_nopic_2026-01.zim|entry_path=Java_Media_Framework]`_`f
• `F33f`_`[IntelliJ IDEA`:/page/entry.mu`zim=wikipedia_de_all_nopic_2026-01.zim|entry_path=IntelliJ_IDEA]`_`f
>>Beispiel
Das folgende Beispiel lädt die `F33f`_`[Standard C Library`:/page/entry.mu`zim=wikipedia_de_all_nopic_2026-01.zim|entry_path=Standard_C_Library]`_`f, um die `F33f`_`[printf`:/page/entry.mu`zim=wikipedia_de_all_nopic_2026-01.zim|entry_path=Printf]`_`f-Funktion aufzurufen. Dieses Beispiel funktioniert auf `F33f`_`[Microsoft Windows`:/page/entry.mu`zim=wikipedia_de_all_nopic_2026-01.zim|entry_path=Microsoft_Windows]`_`f und `F33f`_`[Linux`:/page/entry.mu`zim=wikipedia_de_all_nopic_2026-01.zim|entry_path=Linux]`_`f / `F33f`_`[Unix`:/page/entry.mu`zim=wikipedia_de_all_nopic_2026-01.zim|entry_path=Unix]`_`f / `F33f`_`[Mac OS X`:/page/entry.mu`zim=wikipedia_de_all_nopic_2026-01.zim|entry_path=Mac_OS_X]`_`f.
`B100`F9d9import com.sun.jna.Library;`f`b
`B100`F9d9import com.sun.jna.Native;`f`b
`B100`F9d9import com.sun.jna.Platform;`f`b
`B100`F9d9`f`b
`B100`F9d9/** Einfaches Beispiel einer Deklaration und Nutzung einer Dynamischen Programmbibliothek bzw. "shared library". */`f`b
`B100`F9d9public class HelloWorld {`f`b
`B100`F9d9 public interface CLibrary extends Library {`f`b
`B100`F9d9 CLibrary INSTANCE = (CLibrary)Native.loadLibrary((Platform.isWindows() ? "msvcrt" : "c"),`f`b
`B100`F9d9 CLibrary.class);`f`b
`B100`F9d9`f`b
`B100`F9d9 void printf(String format, Object... args);`f`b
`B100`F9d9 }`f`b
`B100`F9d9`f`b
`B100`F9d9 public static void main(String[] args) {`f`b
`B100`F9d9 CLibrary.INSTANCE.printf("Hello, World\\n");`f`b
`B100`F9d9 for (int i=0;i < args.length;i++) {`f`b
`B100`F9d9 CLibrary.INSTANCE.printf("Argument %d: %s\\n", i, args[i]);`f`b
`B100`F9d9 }`f`b
`B100`F9d9 }`f`b
`B100`F9d9}`f`b
>>Weblinks
• Java Native Access Homepage (englisch)
• Java Native Access – Download page (englisch)
• Java Native Access – User Mailing List (englisch)
>>Einzelnachweise
`:cite-note-1`!1.`! `F0af`_`[↑`#cite-ref-1]`_`f github.com
`:cite-note-2`!2.`! `F0af`_`[↑`#cite-ref-2]`_`f `*Default Type Mappings.`* jna.dev.java.net, abgerufen am 2. August 2011.
`c`F0af`_`[↑ Back to top`#top]`_`f`a